package it.uniroma3.dia.ia.textcategorization.categorizer;

import it.uniroma3.dia.ia.textcategorization.categorizer.opennlp.OpenNLPCategorizerBuilder;
import it.uniroma3.dia.ia.textcategorization.texcat.TexCatConfiguration;

import java.util.HashMap;
import java.util.Map;

/**
 * 
 * Factory class for CategorizerBuilder's instances polymorphic creation.
 * 
 * @author Marco Liceti
 *
 */
public final class CategorizerBuilderFactory {
	
	private static final Map<String, CategorizerBuilder> map = new HashMap<String, CategorizerBuilder>();
	
	/**
	 * Default CategorizerBuilder's name.
	 */
	public static final String DEFAULT = TexCatConfiguration.getDefaultCategorizerBuilderName();
	/**
	 * Apache OpenNLP CategorizerBuilder's name.
	 */
	public static final String OPEN_NLP = "opennlp";
	
	static {
		map.put(OPEN_NLP, new OpenNLPCategorizerBuilder());
	}
	
	/**
	 * @return the default CategorizerBuilder.
	 */
	public static CategorizerBuilder newCategorizerBuilder() {
		return map.get(DEFAULT);
	}
	
	/**
	 * 
	 * Returns the named CategorizerBuilder.
	 * 
	 * @param categorizerName The name of the desired CategorizerBuilder.
	 * @return the desired CategorizerBuilder.
	 */
	public static CategorizerBuilder newCategorizerBuilder(String categorizerName) {
		return map.get(categorizerName);
	}

}